"""CLI entry point for launching a demo agent runtime."""
from __future__ import annotations

import argparse
import asyncio

from agent_society.runtime.core import AgentRuntime, LedgerClient, PersonaManifest
from agent_society.telemetry.logging import configure_logging


async def main() -> None:
    parser = argparse.ArgumentParser(description="Run demo Agent-Society runtime")
    parser.add_argument("--ledger", default="http://localhost:8080", help="Ledger base URL")
    parser.add_argument("--account", default="atlas", help="Compute account name")
    parser.add_argument("--prompt", default="Explain compute survival", help="Task prompt")
    args = parser.parse_args()

    configure_logging()
    manifest = PersonaManifest(
        name="atlas",
        role="research",
        objectives=["synthesize knowledge", "support governance"],
        compute_account=args.account,
    )
    ledger = LedgerClient(args.ledger, args.account)
    runtime = AgentRuntime(manifest, ledger)
    runtime.ingest_memory(
        [
            "Compute credits track how much work an agent can execute.",
            "Agents consult the governance charter before initiating fusion events.",
            "Telemetry dashboards capture task success rates and token usage.",
        ]
    )
    result = await runtime.perform_task(args.prompt)
    print(result["result"])


if __name__ == "__main__":
    asyncio.run(main())
